#include <stdio.h>
int main()
{
    int a,b;
    for ( a = 0; a <= 100000; a++)
    {
        for (;a < 0;)
        {
            b = a % 10;
            if (b == 6)
            {
                printf("%d\n",a);
            }
            a = a / 10;
        }
        
        if (a%6 == 0)
        {
            printf("%d\n",a);
        }
        
    }
    return 0;
}